home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Taiji Applet Pack v2.7 / Chat / Friends$TextFieldKey.class (.txt) < prev   
Encoding:
Java Class File  |  2001-11-06  |  2.8 KB  |  113 lines

  1. import java.awt.event.KeyAdapter;
  2. import java.awt.event.KeyEvent;
  3. import java.util.EventObject;
  4.  
  5. class Friends$TextFieldKey extends KeyAdapter {
  6.    // $FF: synthetic field
  7.    private final Friends this$Friends;
  8.  
  9.    public void keyPressed(KeyEvent event) {
  10.       Object object = ((EventObject)event).getSource();
  11.       if (object == this.this$Friends.textfield) {
  12.          int key = event.getKeyCode();
  13.          switch (key) {
  14.             case 17:
  15.                try {
  16.                   String text = this.this$Friends.textfield.getText();
  17.                   if (text == null) {
  18.                      return;
  19.                   }
  20.  
  21.                   text = text.trim();
  22.                   if (text.equals("")) {
  23.                      return;
  24.                   }
  25.  
  26.                   int p = text.length() - 1;
  27.  
  28.                   while(text.charAt(p) != ' ') {
  29.                      --p;
  30.                      if (p < 0) {
  31.                         p = -1;
  32.                         break;
  33.                      }
  34.                   }
  35.  
  36.                   text = text.substring(p + 1);
  37.                   int q = 0;
  38.                   int r = 0;
  39.  
  40.                   for(int i = 0; i < this.this$Friends.list.getItemCount(); ++i) {
  41.                      if (this.this$Friends.list.getItem(i).startsWith(text)) {
  42.                         r = i;
  43.                         ++q;
  44.                      }
  45.                   }
  46.  
  47.                   if (q == 1) {
  48.                      this.this$Friends.textfield.setText(this.this$Friends.textfield.getText().substring(0, p + 1) + this.this$Friends.list.getItem(r));
  49.                      this.this$Friends.textfield.setCaretPosition(this.this$Friends.textfield.getText().length());
  50.                      return;
  51.                   }
  52.                   break;
  53.                } catch (Exception var11) {
  54.                   System.out.println("exception !! je capture");
  55.                   return;
  56.                }
  57.             case 38:
  58.                try {
  59.                   if (this.this$Friends.count > 29) {
  60.                      return;
  61.                   }
  62.  
  63.                   --this.this$Friends.lht;
  64.                   ++this.this$Friends.count;
  65.                   if (this.this$Friends.lht < 0) {
  66.                      if (this.this$Friends.history[29] != null) {
  67.                         this.this$Friends.lht = 29;
  68.                      } else {
  69.                         this.this$Friends.lht = 0;
  70.                      }
  71.                   }
  72.  
  73.                   this.this$Friends.textfield.setText(this.this$Friends.history[this.this$Friends.lht]);
  74.                   this.this$Friends.textfield.setCaretPosition(this.this$Friends.textfield.getText().length());
  75.                   return;
  76.                } catch (Exception var10) {
  77.                   System.out.println("exception !! je capture");
  78.                   return;
  79.                }
  80.             case 40:
  81.                try {
  82.                   if (this.this$Friends.count - 1 == 0) {
  83.                      return;
  84.                   }
  85.  
  86.                   ++this.this$Friends.lht;
  87.                   --this.this$Friends.count;
  88.                   if (this.this$Friends.lht > 29) {
  89.                      this.this$Friends.lht = 0;
  90.                   }
  91.  
  92.                   if (this.this$Friends.lht == this.this$Friends.lh) {
  93.                      this.this$Friends.lht = this.this$Friends.lh - 1;
  94.                   }
  95.  
  96.                   this.this$Friends.textfield.setText(this.this$Friends.history[this.this$Friends.lht]);
  97.                   this.this$Friends.textfield.setCaretPosition(this.this$Friends.textfield.getText().length());
  98.                   return;
  99.                } catch (Exception var9) {
  100.                   System.out.println("exception !! je capture");
  101.                   return;
  102.                }
  103.          }
  104.       }
  105.  
  106.    }
  107.  
  108.    Friends$TextFieldKey(Friends this$Friends) {
  109.       this.this$Friends = this$Friends;
  110.       this.this$Friends = this$Friends;
  111.    }
  112. }
  113.